package com.wmx.thread.synchronize_and_lock;

/**********************************
 * @author wmx
 * @date 2019/8/20 15:19
 * @description:
 * @version 1.0
 ************************************/
public class SynchronizeTest {
   private final static Object obj = new Object();
    public static void main(String[] args) {
        new Thread(()->{
            synchronized (obj){
                System.out.println("线程"+Thread.currentThread().getName()+"获得锁");
                try {
                    obj.wait();
                    System.out.println("线程"+Thread.currentThread().getName()+"再次获得锁");
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();

        new Thread(()->{
            synchronized (obj){
                System.out.println("线程"+Thread.currentThread().getName()+"获得锁");
                 obj.notify();
            }
        }).start();
    }
}
